Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvserver: use wrapper type for Store.mu.replicas #72430

Merged
merged 3 commits into from
Nov 4, 2021

Conversation

tbg
Copy link
Member

@tbg tbg commented Nov 4, 2021

This simplifies lots of callers and it will also make it easier to work
on #72374, where this map will start containing more than one type as
value.

Release note: None

@tbg tbg requested a review from a team as a code owner November 4, 2021 14:05
@tbg tbg requested a review from erikgrinaker November 4, 2021 14:05
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@erikgrinaker erikgrinaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 7 of 7 files at r1, 1 of 6 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @erikgrinaker and @tbg)


pkg/kv/kvserver/store_replicas_by_rangeid.go, line 23 at r1 (raw file):

type rangeIDReplicaMap struct {
	m syncutil.IntMap

nit: consider calling this replicas or something -- m.m is a bit terse.


pkg/kv/kvserver/store_replicas_by_rangeid.go, line 52 at r1 (raw file):

// returned from the closure to stop iteration without an error
// resulting from Range().
func (m *rangeIDReplicaMap) Range(f func(*Replica) error) error {

nit: looks like we're never returning an error from the closure, so I wonder if it'd be just as easy to return a bool here for consistency with sync.Map and avoid the errcheck appeasement.

This simplifies lots of callers and it will also make it easier to work
on cockroachdb#72374, where this map will start containing more than one type as
value.

Release note: None
- avoid the struct wrapper (and thus the need to name the inner map)
- don't return an error in Range()

Release note: None
@tbg
Copy link
Member Author

tbg commented Nov 4, 2021

TFTR! I addressed your comments.

bors r=erikgrinaker

@craig
Copy link
Contributor

craig bot commented Nov 4, 2021

Build succeeded:

@craig craig bot merged commit ed35bbe into cockroachdb:master Nov 4, 2021
@tbg tbg deleted the store-clarify-maps branch November 4, 2021 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants